package com.mine.modules.vm.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mine.common.annotation.vm.TreeChildrenAnnotation;
import com.mine.common.annotation.vm.TreeIdAnnotation;
import com.mine.common.annotation.vm.TreeParentIdAnnotation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 场景菜单表
 * </p>
 *
 * @author author
 * @since 2024-10-09
 */
@Data
@ApiModel("菜单实体")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("vm_permission")
public class VmPermission implements Serializable {

    private static final long serialVersionUID = 1L;

    @TreeIdAnnotation("id")
    @TableId(type = IdType.ASSIGN_ID)
    private String id;

    @ApiModelProperty("父id")
    @TreeParentIdAnnotation("parentId")
    private String parentId;

    @ApiModelProperty("菜单名称")
    private String name;

    @ApiModelProperty("菜单图标")
    private String icon;

    @ApiModelProperty("组件")
    private String component;

    @ApiModelProperty("组件名字")
    private String componentName;

    @ApiModelProperty("路径")
    private String path;

    @ApiModelProperty("一级菜单跳转地址")
    private String redirect;

    @ApiModelProperty("菜单排序")
    private Double sortNo;

    @ApiModelProperty("类型（0：一级菜单；1：子菜单）")
    private Integer menuType;

    @ApiModelProperty("是否路由菜单0:不是  1:是（默认值1）")
    @TableField(value="is_route")
    private boolean route;

    private String createBy;

    @ApiModelProperty("是否隐藏路由菜单: 0否,1是（默认值0）")
    private boolean hidden;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    private String updateBy;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    private boolean internalOrExternal;

    @TableField(exist = false)
    @TreeChildrenAnnotation("children")
    private List<VmPermission> children;

    public VmPermission() {
    }
    public VmPermission(boolean index) {
        if(index) {
            this.id = "9502685863ab87f0ad1134142788a385";
            this.name="首页";
            this.component="dashboard/Analysis";
            this.componentName="dashboard-analysis";
            this.path="/dashboard/analysis";
            this.icon="home";
            this.menuType=0;
            this.sortNo=0.0;
            this.route=true;
            this.hidden=false;
        }

    }

}
